package testenv.model.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import testenv.model.AbstractBaseEntity;



@Entity
@SequenceGenerator(name="structureelementgroup_id_seq", sequenceName="structureelementgroup_id_sequence")
public class StructureElementGroup extends AbstractBaseEntity {
	private static final long serialVersionUID = 1L;
	
	
	public StructureElementGroup() {
	}
	
	public StructureElementGroup(ElementGroup elementGroup, StructureVersion structureVersion) {
		this.elementGroup = elementGroup;
		this.structureVersion = structureVersion;
	}
	
	@Id
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="structureelementgroup_id_seq")
	@GenericGenerator(
	     name="structureelementgroup_id_seq",
	     strategy="sequence",
	     parameters= {
	         @Parameter(name="minvalue", value="1"),
	         @Parameter(name="increment", value="1"),
	         @Parameter(name="sequence", value="structureelementgroup_id_sequence")
	         })
	private Integer id = null;
	
		
	@ManyToOne
	private StructureVersion structureVersion = null;
	
	@ManyToOne
	private ElementGroup elementGroup = null;
	
	@OneToMany(mappedBy="structureElementGroup", cascade=CascadeType.ALL)
	@org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
	private Set<Element> elementSet = new HashSet<Element>();
	
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public StructureVersion getStructureVersion() {
		return structureVersion;
	}

	public void setStructureVersion(StructureVersion structureVersion) {
		this.structureVersion = structureVersion;
	}

	public ElementGroup getElementGroup() {
		return elementGroup;
	}

	public void setElementGroup(ElementGroup elementGroup) {
		this.elementGroup = elementGroup;
	}

	public Set<Element> getElementSet() {
		return elementSet;
	}

	public void setElementSet(Set<Element> elementSet) {
		this.elementSet = elementSet;
	}
	
	
}
